package zzz.Text.text9;

import java.util.ArrayList;
import java.util.Scanner;

public class Student_Tools {
    public static void search(ArrayList<Student_Property> list){
        for (int i = 0; i < list.size(); i++) {
            String sname = list.get(i).getUsername();
            int num = list.get(i).getPassword();
            System.out.println(sname);
            System.out.println(num);
        }
    }
    public static boolean containProperty(ArrayList<Student_Property> list,String name,int number){
        for (int i = 0; i < list.size(); i++) {
            String sname = list.get(i).getUsername();
            int num = list.get(i).getPassword();
            if(sname.equals(name)&&num == number){
                return true;
            }
        }
        return false;
    }
    public static void Record(ArrayList<Student_Property> list){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名");
        String name = sc.next();
        System.out.println("请输入登录密码");
        int number =sc.nextInt();
        boolean flag = containProperty(list,name,number);
        if(flag){
            System.out.println("登录成功");
        }else{
            System.out.println("登录失败");
        }
    }
    public static void Register(ArrayList<Student_Property> list){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名");
        String name = sc.next();
        System.out.println("请输入登录密码");
        int number =sc.nextInt();
        System.out.println("请输入电话号码");
        int phone = sc.nextInt();
        Student_Property stu = new Student_Property(name,number,phone);
        list.add(stu);
    }
}
